﻿@model PluginModel

@Html.ValidationSummary(false)
@Html.HiddenFor(model => model.SystemName)

@if (ViewBag.RefreshPage == true)
{
    <script type="text/javascript">
        try {window.opener.document.forms['@(ViewBag.formId)'].@(ViewBag.btnId).click();}
        catch (e){}
        window.close();
    </script>
}

<div class="content">
    <div class="form-horizontal">
        <div class="panel-group">
            <div class="panel panel-default panel-popup">
                <div class="panel-body">
                    @(Html.LocalizedEditor<PluginModel, PluginLocalizedModel>("plugin-localized",
                @<div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            @Html.NopLabelFor(model => model.Locales[item].FriendlyName)
                        </div>
                        <div class="col-sm-9">
                            @Html.NopEditorFor(model => model.Locales[item].FriendlyName)
                            @Html.ValidationMessageFor(model => model.Locales[item].FriendlyName)
                        </div>
                    </div>
                    @Html.HiddenFor(model => model.Locales[item].LanguageId)
                </div>
    ,
                    @<div>
                        <div class="form-group">
                            <div class="col-sm-3">
                                @Html.NopLabelFor(model => model.FriendlyName)
                            </div>
                            <div class="col-sm-9">
                                @Html.NopEditorFor(model => model.FriendlyName, required: true)
                                @Html.ValidationMessageFor(model => model.FriendlyName)
                            </div>
                        </div>
                    </div>
    ))

                    <div class="form-group">
                        <div class="col-sm-3">
                            @Html.NopLabelFor(model => model.DisplayOrder)
                        </div>
                        <div class="col-sm-9">
                            @Html.NopEditorFor(model => model.DisplayOrder)
                            @Html.ValidationMessageFor(model => model.DisplayOrder)
                        </div>
                    </div>
                    @if (Model.CanChangeEnabled)
                    {
                        <div class="form-group">
                            <div class="col-sm-3">
                                @Html.NopLabelFor(model => model.IsEnabled)
                            </div>
                            <div class="col-sm-9">
                                @Html.NopEditorFor(model => model.IsEnabled)
                                @Html.ValidationMessageFor(model => model.IsEnabled)
                            </div>
                        </div>
                    }
                    <div class="form-group">
                        <div class="col-sm-3">
                            @Html.NopLabelFor(model => model.SelectedCustomerRoleIds)
                        </div>
                        <div class="col-sm-9">
                            @Html.EditorFor(model => model.SelectedCustomerRoleIds, new { SelectList = Model.AvailableCustomerRoles })
                            <script>
                                $(document).ready(function() {
                                    var rolesIdsInput = $('#@Html.FieldIdFor(model => model.SelectedCustomerRoleIds)').data("kendoMultiSelect");
                                    rolesIdsInput.setOptions({
                                        autoClose: false
                                    });

                                    @if (Model.AvailableCustomerRoles.Count == 0)
                                    {
                                        <text>
                                            rolesIdsInput.setOptions({
                                                enable: false,
                                                placeholder: 'No customer roles available'
                                            });
                                            rolesIdsInput._placeholder();
                                            rolesIdsInput._enable();
                                        </text>
                                    }
                                });
                            </script>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            @Html.NopLabelFor(model => model.SelectedStoreIds)
                        </div>
                        <div class="col-sm-9">
                            <div class="row">
                                <div class="col-sm-4">
                                    @Html.EditorFor(model => model.SelectedStoreIds, new {SelectList = Model.AvailableStores})
                                    <script>
                                        $(document).ready(function() {
                                            var storesIdsInput = $('#@Html.FieldIdFor(model => model.SelectedStoreIds)').data("kendoMultiSelect");
                                            storesIdsInput.setOptions({
                                                autoClose: false
                                            });

                                            @if (Model.AvailableStores.Count == 0)
                                            {
                                                <text>
                                                    storesIdsInput.setOptions({
                                                        enable: false,
                                                        placeholder: 'No stores available'
                                                    });
                                                    storesIdsInput._placeholder();
                                                    storesIdsInput._enable();
                                                </text>
                                            }
                                        });
                                    </script>
                                </div>
                                <div class="col-sm-8">
                                    @Html.Action("MultistoreDisabledWarning", "Common")
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>